/*
 * Copyright (C) 2015-2017 Alibaba Group Holding Limited
 */
#ifndef _PIN_CONFIG_H_
#define _PIN_CONFIG_H_

#include <pin_name.h>
#include <soc.h>
#include <pinmux.h>

//配置测试用的串口端号
#ifndef CONSOLE_IDX
#define CONSOLE_IDX 0
#endif

//配置ADC参数
#ifdef TEST_ADC
#define ADC1_PORT_NUM 4
#endif

//配置FLASH参数
#ifdef TEST_EFLASH
#endif

#ifdef TEST_SPIFLASH
#endif

//配置GPIO参数
#ifdef TEST_GPIO
#define GPIO_LED_IO PA14
#define GPIO_BUTTON_IO PA15
#define GPIO_BUTTON_IO2 PA13
#define PIN_GPIO_BUTTON_FUNC PIN_FUNC_GPIO
#endif

//配置IIC参数,当IIC存在MASTER和SLAVE模式
#ifdef TEST_IIC_MASTER_AND_SLAVE

#define CK_IIC_SLAVE_ADDR         0x50
#define EEPROM_PAGE_ADDR          0x00

#define I2C_PORT_NUM  0
#define PIN_IIC_SDA             PA07
#define PIN_IIC_SCL             PA06
#define PIN_IIC_SDA_FUNC        AF_I2C1_SDA
#define PIN_IIC_SCL_FUNC        AF_I2C1_SCL

#define I2C_DEV_ADDR       0x40

#endif

//配置PWM参数
#ifdef TEST_PWM
#define PWM_PORT_PIN_CH                 0
#define PWM_PORT_PIN_NAME               PA00
#define PWM_PORT_PIN_FUNC               AF_ADTIM1_CH1

#define GPIO_BUTTON_IO_1 PA07
#define GPIO_BUTTON_IO_2 PA09
#endif

//配置RNG参数
#ifdef TEST_RNG
#define RNG1_PORT_NUM 0
#endif

//配置RTC参数
#ifdef TEST_RTC
#define RTC1_PORT_NUM 0
#define RTC2_PORT_NUM 1
#endif

//配置SPI参数,当SPI存在MASTER和SLAVE模式
#ifdef TEST_SPI_MASTER_AND_SLAVE
#define SPI_PORT_NUM  1
#define SPI_MOSI  	PA08
#define SPI_MISO  	PA09
#define SPI_SCK  	PA10
#define SPI_CS  	PA11
#define SPI_MOSI_FUNC		AF_SPI2_MOSI
#define SPI_MISO_FUNC		AF_SPI2_MISO
#define SPI_SCK_FUNC	AF_SPI2_SCK
#define SPI_CS_FUNC		AF_SPI2_NSS
#endif

//配置TIMER参数
#ifdef TEST_TIMER
#define TIMER0_PORT_NUM 0
#define TIMER1_PORT_NUM 1
#define TIMER2_PORT_NUM 2
#define TIMER3_PORT_NUM 3
#endif

//配置UART参数
#ifdef TEST_UART
#define UART1_PORT_NUM  2
#endif

//配置WDT参数
#ifdef TEST_WDT
#define WDG_PORT_NUM 0
#endif

//配置IIC参数,当IIC仅存在MASTER模式
#ifdef TEST_IIC

#define CK_IIC_SLAVE_ADDR         0x50
#define EEPROM_PAGE_ADDR          0x00

#define I2C_PORT_NUM  0
#define PIN_IIC_SDA             PA07
#define PIN_IIC_SCL             PA06
#define PIN_IIC_SDA_FUNC_NO_SLAVE        AF_I2C1_SDA
#define PIN_IIC_SCL_FUNC_NO_SLAVE        AF_I2C1_SCL

#define I2C_DEV_ADDR       0x40

#endif

//配置SPI参数,当SPI仅存在MASTER模式
#ifdef TEST_SPI
#define SPI_PORT_NUM  1
#define SPI_MOSI  	PA08
#define SPI_MISO  	PA09
#define SPI_SCK  	PA10
#define SPI_CS  	PA11
#define SPI_MOSI_FUNC		AF_SPI2_MOSI
#define SPI_MISO_FUNC		AF_SPI2_MISO
#define SPI_SCK_FUNC_NO_SLAVE	AF_SPI2_SCK
#define SPI_CS_FUNC_NO_SLAVE		AF_SPI2_NSS
#endif

#endif